<template>
  <!-- <th-card title="资料收集"> -->
  <view class="info-list">
    <view v-for="item in form.rdInformationDTO" :key="item.id" class="info-list-main">
      <view class="info-list-row">
        <view class="info-list-label">资料名称</view>
        <view class="info-list-value">{{ item.informationName }}</view>
        <view v-if="item.delFlag == 1">
          <wd-tag plain bg-color="red" color="red">废弃</wd-tag>
        </view>
      </view>
      <view class="info-list-row">
        <view class="info-list-label">资料描述</view>
        <view class="info-list-value">{{ item.informationDesc }}</view>
      </view>
      <view
        class="info-list-row"
        v-if="item.rdInformationProfileEntity && item.rdInformationProfileEntity.length"
      >
        <view class="info-list-label">附件</view>
        <view class="info-list-value">
          <view style="display: flex; flex-direction: column">
            <view
              v-for="file in item.rdInformationProfileEntity
                .filter((item) => item.profileType != 'web')
                .filter((item) => item.delFlag != 1)"
              :key="file.id"
              @click="previewFileHandle(file.profileUrl)"
              class="info-row-item"
            >
              {{ file.profileInfo }}
            </view>
          </view>
        </view>
      </view>
      <view class="info-list-row" v-if="item.informationWeb">
        <view class="info-list-label">网址</view>
        <view class="info-list-value info-row-item" @click="previewWeb(item.informationWeb)">
          {{ item.informationWeb }}
        </view>
      </view>
    </view>
  </view>
  <!-- </th-card> -->

  <!-- <th-card title="附件"> -->
  <th-form-item
    label="综述"
    class="form-demandDesc"
    v-if="form.sampleReviewConclusion"
    style="border-bottom: 1px solid #eff3fd"
  >
    <text class="text">{{ form.sampleReviewConclusion }}</text>
  </th-form-item>
  <!-- </th-card> -->
  <th-form-item label="回复" class="form-demandDesc" v-if="form.reply">
    <text class="text">{{ form.reply }}</text>
  </th-form-item>
  <!-- <th-card title="调查问卷"> -->
  <view class="info-list">
    <view class="info-list-main">
      <view class="info-list-row">
        <view class="info-list-label">附件</view>
        <view class="info-list-value">
          <view style="display: flex; flex-direction: column">
            <view
              v-for="file in form.rdTaskFileEntity"
              :key="file.id"
              @click="previewFileHandle(file.fileUrl)"
              class="info-row-item"
            >
              {{ file.fileName }}
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
  <th-form-item label="需求反馈方式" class="form-demandDesc" v-if="form.replyNeed != 3">
    <text class="text">
      <!-- {{ form.replyNeed == 1 ? '回复' : form.replyNeed == 0 ? '不回复' : '' }} -->
      {{ getReplyNeed(form.replyNeed) }}
    </text>
  </th-form-item>
  <!-- </th-card> -->
</template>
<script lang="tsx" setup>
const form = reactive({
  rdInformationDTO: [],
  rdCraftEntity: [],
  rdTaskFileEntity: [],
  sampleReviewConclusion: '',
  reply: '',
  replyNeed: 3,
});

const init = (row) => {
  form.rdInformationDTO = row.rdInformationDTO;
  form.rdCraftEntity = row.rdCraftEntity;
  form.rdTaskFileEntity = row.rdTaskFileEntity;
  form.sampleReviewConclusion = row.sampleReviewConclusion;
  form.reply = row.reply;
  form.replyNeed = row.replyNeed;
};

const previewFileHandle = (file) => {
  uni.navigateTo({
    url: `/pages/pm/preview-online?url=${file}`,
  });
};

const previewWeb = (url) => {
  uni.navigateTo({
    url: `/pages/pm/preview-online?url=${url}&isWeb=1`,
  });
};

const getReplyNeed = (replyNeed) => {
  if (replyNeed == 3) return '';
  const replyList = [
    {
      label: '不反馈',
      value: 0,
    },
    {
      label: '直接反馈',
      value: 1,
    },
    {
      label: '总经理确认后反馈',
      value: 2,
    },
  ];

  const o = replyList.find((item) => item.value == replyNeed);
  return o ? o.label : '';
};

defineExpose({
  init,
});
</script>

<style lang="scss" scoped>
.info-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.info-list-main {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10rpx;
  margin: 10rpx 0;

  // border: 1px solid #e3e3e3;
  border-bottom: 1px solid #eff3fd;

  // border-radius: 8rpx;

  .info-list-row {
    display: flex;
    width: 100%;

    .info-list-label {
      width: 160rpx;
      padding-left: 13rpx;
      margin-right: 15rpx;
      font-size: 28rpx;
      color: #808080;
    }

    .info-list-value {
      display: flex;
      flex: 1;
      align-items: center;
      width: 0;
      word-break: break-all;
      white-space: pre-line;
    }
  }
}

.craft-row {
  display: flex;
  align-items: center;

  .craft-row-img-main {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 0;
  }
}

.craft-row-img {
  width: 240rpx;
  height: 240rpx;
}

.form-demandDesc {
  align-items: flex-start !important;
  padding-left: 23rpx;
  margin: 0 !important;

  .text {
    word-break: break-all;
  }
}
</style>
